//
//  SubTaskTableViewCell.m
//  lsOA
//
//  Created by 蓝水软件 on 16/8/16.
//  Copyright © 2016年 苏州蓝水有限公司. All rights reserved.
//

#import "SubTaskTableViewCell.h"

@implementation SubTaskTableViewCell{
    UILabel *state;
    UILabel *subTaskTitle;
    UILabel *timeLabel;
    UILabel *isNeedperform;
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

//- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        subTaskTitle = [[UILabel alloc]init];
        [self.contentView addSubview:subTaskTitle];
        [subTaskTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo (0);
        }];
        
        state = [[UILabel alloc]init];
        state.textAlignment = NSTextAlignmentRight;
        state.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:state];
        [state mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(subTaskTitle.mas_top).offset(3);
            make.right.mas_equalTo(-30);
            make.width.mas_equalTo(KSWidth);
            make.height.mas_equalTo(10*FitSize);
        }];
        
        timeLabel = [[UILabel alloc]init];
        timeLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:timeLabel];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(subTaskTitle.mas_bottom).offset(3);
            make.left.mas_equalTo(15);
            make.width.mas_equalTo(130*FitSize);
            make.height.mas_equalTo(10*FitSize);
        }];
        
        isNeedperform = [[UILabel alloc]init];
        [self.contentView addSubview:isNeedperform];
        [isNeedperform mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(timeLabel.mas_right).offset(5);
            make.centerY.equalTo(timeLabel);
        }];
        isNeedperform.font = [UIFont systemFontOfSize:12];
        
        UIImageView *rightImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"right"]];
        [self.contentView addSubview:rightImage];
        [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(0);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(35, 35));
        }];
        
        UIView *line = [[UIView alloc]init];
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(1);
            make.bottom.mas_equalTo(-1);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
        }];
        line.backgroundColor = [UIColor lightGrayColor];
        
    }
    return self;
}

- (void)configWithDic:(NSDictionary *)dic{
    NSLog(@"任务子列表 %@",dic);
    switch ([dic[@"dStatus"] intValue]) {
        case 0:{
            state.text = @"进行中";
            state.textColor = [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000];
        
        }
            break;
        case 1:{
            state.text = @"完成";
            state.textColor = [UIColor colorWithRed:0.000 green:1.000 blue:0.502 alpha:1.000];
        }
            break;
        case -1:{
            state.text = @"停止";
            state.textColor = [UIColor redColor];
        }
            break;
    }
    subTaskTitle.text = dic[@"DetailTitle"];
    timeLabel.text = dic[@"dAddTime"];
    
    if ([dic[@"isExecute"] isEqualToString:@"1"]) {
        isNeedperform.text = @"需要我执行";
        isNeedperform.textColor = [UIColor redColor];
    }else{
    
        isNeedperform.text = @"不要我执行";
        isNeedperform.textColor = [UIColor colorWithRed:0.251 green:0.502 blue:0.000 alpha:1.000];
    }
    
}






@end
